package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 房间朝向枚举类
 * @author hans.zhang
 */
@Getter
@AllArgsConstructor
public enum TowardEnum {
    SOUTH("1","朝南"),
    NORTH("2","朝北"),
    EAST("3","朝东"),
    WEST("4","朝西"),
    EASTSOUTH("5","东南"),
    WESTSOUTH("7","西南"),
    EASTNORTH("6","东北"),
    WESTNORTH("8","西北"),
    ;
    private String value;
    private String name;

    public static String getValueByName(String name) {
        TowardEnum towardEnum = Arrays.stream(TowardEnum.values()).filter(p -> p.name.equals(name)).findFirst().orElse(null);
        Assert.isTrue(towardEnum != null,"TowardEnum类型:{}不存在",name);
        return towardEnum.getValue();
    }

    public static String getNameByValue(String value) {
        TowardEnum towardEnum = Arrays.stream(TowardEnum.values()).filter(p -> p.value.equals(value)).findFirst().orElse(null);
        Assert.isTrue(towardEnum != null,"TowardEnum类型:{}不存在",value);
        return towardEnum.getName();
    }

}
